package com.itheima.Opertor;

public class OpertorDemo1 {
    public static void main(String[] args) {
        //掌握基本运算符的使用
        int a = 10;
        a += 5; //相当于a=a+5
        System.out.println(a);  //15
        //-= *= /= %=
        a -= 5;
        System.out.println(a);  //5
        a *= 5;//相当于a=a*5
        System.out.println(a);  //25
        a /= 5;
        System.out.println(a);  //5.0
        a %= 5;
        System.out.println(a);  //0


        System.out.println(5 / 2); //2
        System.out.println(1.0 * 5 / 2); //2.5
        System.out.println(5.0 / 2); //2.5

        int d =10;
        int e = 3;
        System.out.println(d +e);   //13
        System.out.println(d - e);  //7
        System.out.println(d * e);  //30
        System.out.println(d / e); //3

        //掌握使用+运算符拼接字符串
        int a2 = 10;
        System.out.println("a2的值是：" + a2);  //a2的值是：10
        System.out.println("a2的值是：" + a2 + 10);  //a2的值是：1010
        System.out.println(10 + "a2的值是：" + a2); //10a2的值是：10
        System.out.println(10 + "a2的值是：" + a2 + 10); //10a2的值是：1010
        //注意：+运算符在拼接字符串时，如果其中一个操作数是数字类型，则先将数字转换为字符串再进行拼接。
        int b = 10;
        String c = "abc";
        System.out.println(b + c);  //10abc
        System.out.println(c + b);  //ab10

    }
}
